package com.cskaoyan.mapper;

import com.cskaoyan.bean.Admin;
import com.cskaoyan.bean.AdminExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AdminMapper {
    long countByExample(AdminExample example);

    int deleteByExample(AdminExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Admin record);

    int insertSelective(Admin record);

    List<Admin> selectByExample(AdminExample example);

    Admin selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Admin record, @Param("example") AdminExample example);

    int updateByExample(@Param("record") Admin record, @Param("example") AdminExample example);

    int updateByPrimaryKeySelective(Admin record);

    int updateByPrimaryKey(Admin record);

    @Select("select password from cskaoyanmall_admin where username = #{username}")
    List<String> selectPasswordByName(@Param("username") String username);

    @Select("SELECT permission FROM cskaoyanmall_permission p " +
            "WHERE p.role_id IN(select substring(role_ids,2,1) as role_ids " +
            "from cskaoyanmall_admin where username = #{username} )")
    List<String> selectPermissionByUsername(@Param("username") String username);

    List<Admin> selectAdminByName(@Param("username") String username);

    List<String> selectPermissionByRoleId(@Param("username") String[] roleIds);

}